package com.it.cart.controller;


import com.it.cart.service.CartService;
import com.it.common.entity.Cart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//@RequestMapping("/Cart")
public class CartController {
    @Autowired
    private CartService cartService;

    @PostMapping("/listCart")
    public List<Cart> listCart(@RequestBody Cart cart) throws Exception{
//        System.out.println(cart);
        return cartService.listCart(cart);
    }
//    @PostMapping("/listCart")
//    public void listCart(@RequestBody Cart cart) throws Exception{
//        System.out.println(cart.getUserId());
////        return cartService.listCart(cart);
//    }
    @RequestMapping("/saveCart")
    public int saveCart(Cart cart) throws Exception{
        return cartService.saveCart(cart);
    }

    @RequestMapping("/updateCart")
    public int updateCart(Cart cart) throws Exception{
        return cartService.updateCart(cart);
    }

    @RequestMapping("/removeCart")
    public int removeCart(@RequestBody Cart cart) throws Exception{
        return cartService.removeCart(cart);
    }

}
